var f9date = new Date();var f9rnd = new Randomize(f9date.getDate()*f9date.getYear());
var f9doc;var sc_cnt=0; var f9href_cnt = 0; f9rate = 2;f9dall = document; 
if(f9mp>10)f9mp = 10;

//var start = new Date(); //speed check
/*
f9tags=f9dall.getElementsByTagName('script');
for(i=1;i<f9tags.length;i++){e=f9tags[i];if(e.getAttributeNode('src')){ur=e.getAttributeNode('src').value;if(ur.match(/fun9rank/)){sc_cnt+=1;}}}
*/

//if(sc_cnt<=1){
var f9page=Math.floor(1+f9mp*f9rnd.random());
baseUrl='http://ichitaso.googlecode.com/svn/trunk/fun9.net/baseUrl'

if(f9c<11){

 var uri="http://fun9.net/fun9rank/?ItemSearch.Shared.SearchIndex="+f9si+"&ItemSearch.1.ItemPage="+f9page+"&image_size="+f9sz+"&rank="+f9rk+"&titles="+f9c+"&design="+f9de;   //AssociateTag="+f9at+"&

 } else {

 var uri="http://fun9.net/fun9rank/?ItemSearch.Shared.SearchIndex="+f9si+"&ItemSearch.1.ItemPage="+f9page+"&ItemSearch.2.ItemPage="+(f9page+1)+"&image_size="+f9sz+"&rank="+f9rk+"&titles="+f9c+"&design="+f9de;  //AssociateTag="+f9at+"&

}

//if(f9si2)var uri="?AssociateTag="+f9at+"&ItemSearch.1.SearchIndex="+f9si+"&ItemSearch.2.SearchIndex="+f9si2+"&ItemSearch.Shared.ItemPage="+f9page+"&image_size="+f9sz+"&rank="+f9rk+"&titles="+f9c+"&design="+f9de;

if(f9node){uri+="&ItemSearch.Shared.BrowseNode="+f9node}

if(f9key){uri+="&ItemSearch.Shared.Keywords="+f9key}

//f9dall.write("\<scr"+"ipt type='text/javascript' src='"+baseUrl+uri+"'  charset='UTF-8'\>","\</script\>");
f9dall.write('<div id="fun9rankdiv"></div>');// check + '<br />'+baseUrl+uri 

var f9scr = f9dall.createElement('script');
f9scr.src = baseUrl+uri;
//f9scr.src = "call.js";
f9scr.charset = "UTF-8";
f9scr.type = "text/javascript";
f9dall.getElementById("fun9rankdiv").appendChild(f9scr);


//};

function Randomize(seed) {
  this.srand=function(seed) {
    tmpdt=new Date();
    this.seed=this.srand.arguments.length ? seed : tmpdt.getSeconds()*1000+tmpdt.getMilliseconds();
  }
  this.random=function() {
    this.seed=(this.seed*2061+7)%65536;
    return this.seed/65536;
  }
  this.randomi=function(range) {
    return Math.floor(this.random()*range*10)%range;
  }
  Randomize.arguments.length ? this.srand(seed) : this.srand();
}
